<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<%@ page import="java.sql.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=uft-8">
<title>检测登陆页面</title>

</head>
<body>
<%
		request.setCharacterEncoding("utf-8");
		String username1 = request.getParameter("username");
		String password1 = request.getParameter("password");
		boolean flag = false;
		PreparedStatement sql = null;
		ResultSet rs = null;
		Connection conn = null;
	%>

	<%
		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://localhost:3306/jsp";
		String use = "root";
		String password = "root";
		Class.forName(driver);
		 conn= DriverManager.getConnection(url,use,password);
		 sql = conn.prepareStatement("select * from user where username='"+username1+"';");
		rs = sql.executeQuery();
		if (rs.next())
			
			{String password2 = new String(rs.getString("password"));
				if(password2.equals(password1))		
          			 response.sendRedirect("student_system.jsp");
					else  {
          				 response.sendRedirect("fail.jsp");
						}
			}
		else  {
			     
				 response.sendRedirect("fail.jsp");
			}
		
	%>

<a href="success.jsp">here</a>
</body>
</html>